import type { PageResult, ResponseBody } from "@/api/typing";
import { request } from "@/utils/request";
import type {
  SubjectParams,
  DeleteParams,
  QueryParams,
  QueryResult,
} from "./typing";

/**新增学科 */
export const add = (params: SubjectParams) => {
  return request.post<SubjectParams, ResponseBody>(
    "/answer/subject/add",
    params
  );
};

/**修改学科 */
export const update = (params: SubjectParams) => {
  return request.put<SubjectParams, ResponseBody>(
    "/answer/subject/update",
    params
  );
};

/**分页查询学科 */
export const queryByPage = (params: QueryParams) => {
  return request.get<QueryParams, ResponseBody<PageResult<QueryResult>>>(
    "/answer/subject/page",
    { params }
  );
};

/**删除学科 */
export const del = (params: DeleteParams) => {
  return request.delete<DeleteParams, ResponseBody>("/answer/subject/delete", {
    params,
  });
};

/**列表查询学科 */
export const queryByList = () => {
  return request.get<null, ResponseBody<QueryResult[]>>("/answer/subject/list");
};
